/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.patpro.controladores;

import com.patpro.modelo.javabeans.Alumno;
import com.patpro.modelo.servicios.AlumnoServicio;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

/**

 */
public class EliminaAlumnoController extends AbstractController {

    private AlumnoServicio servicio_alumno;

    public AlumnoServicio getServicio_alumno() {
        return servicio_alumno;
    }

    public void setServicio_alumno(AlumnoServicio servicio_alumno) {
        this.servicio_alumno = servicio_alumno;
    }

    public EliminaAlumnoController() {
    }

    protected ModelAndView handleRequestInternal(
            HttpServletRequest request,HttpServletResponse response) throws Exception {
        ModelAndView mv = null;
        String id_alumno = request.getParameter("id");
        int resp = servicio_alumno.eliminarAlumno(new Alumno(Integer.parseInt(id_alumno)));
        if(resp > 0)
            mv = new ModelAndView("exito");
        else
            mv = new ModelAndView("error");
        mv.addObject("controlador", "adminAlumno");
        return mv;
    }
}
